﻿using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using Microsoft.Bot.Connector;
using Newtonsoft.Json;
using System.Collections.Generic;
using Microsoft.Bot.Builder.Dialogs;

namespace BotApp
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                // calculate something for us to return
                int length = (activity.Text ?? string.Empty).Length;

                #region 智能报表应用
                //if (activity.Text == "1")
                //{
                //    Activity reply = activity.CreateReply();
                //    reply.Attachments = new List<Attachment>();
                //    reply.Attachments.Add(new Attachment()
                //    {
                //        ContentUrl = "http://pic6.huitu.com/res/20130116/84481_20130116142820494200_1.jpg",
                //        ContentType = "image/jpg",
                //        Name = "Bender_Rodriguez.jpg"
                //    });

                //    await connector.Conversations.ReplyToActivityAsync(reply);
                //}
                //else if (activity.Text == "Hi")
                //{
                //    Activity replyToConversation = activity.CreateReply("我已经准备好了今天的汇报！");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.Attachments = new List<Attachment>();
                //    List<CardImage> cardImages = new List<CardImage>();
                //    cardImages.Add(new CardImage(url: "http://api.page2images.com/ccimages/f0/b6/HOjVZowBJ0TersO7.png"));
                //    cardImages.Add(new CardImage(url: "http://api.page2images.com/ccimages/f0/b6/HOjVZowBJ0TersO7.png"));
                //    List<CardAction> cardButtons = new List<CardAction>();
                //    CardAction splButton = new CardAction()
                //    {
                //        Value = "start",
                //        Type = "postBack",
                //        Title = "start"

                //    };
                //    cardButtons.Add(splButton);
                //    CardAction AplButton = new CardAction()
                //    {
                //        Value = "5",
                //        Type = "postBack",
                //        Title = "All"
                //    };
                //    cardButtons.Add(AplButton);
                //    CardAction eplButton = new CardAction()
                //    {
                //        Value = "http://botwebchat.chinacloudsites.cn/Bot/Email",
                //        Type = "openUrl",
                //        Title = "Email Me"
                //    };
                //    cardButtons.Add(eplButton);
                //    HeroCard plCard = new HeroCard()
                //    {
                //        Title = "",
                //        Subtitle = "",
                //        Images = cardImages,
                //        Buttons = cardButtons

                //    };
                //    Attachment plAttachment = plCard.ToAttachment();
                //    replyToConversation.Attachments.Add(plAttachment);
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                //}
                //else if (activity.Text == "start")
                //{
                //    Activity reply = activity.CreateReply($"start");
                //    await connector.Conversations.ReplyToActivityAsync(reply);
                //}

                //else if (activity.Text == "3")
                //{
                //    Activity replyToConversation = activity.CreateReply("全部报表如下");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.Attachments = new List<Attachment>();
                //    List<CardImage> cardImages = new List<CardImage>();
                //    cardImages.Add(new CardImage(url: "http://pic.qiantucdn.com/58pic/17/41/38/88658PICNuP_1024.jpg"));
                //    List<CardAction> cardButtons = new List<CardAction>();
                //    CardAction plButton = new CardAction()
                //    {
                //        Value = "https://www.baidu.com",
                //        Type = "openUrl",
                //        Title = "WikiPedia Page"
                //    };
                //    cardButtons.Add(plButton);
                //    ThumbnailCard plCard = new ThumbnailCard()
                //    {
                //        Title = "I'm a thumbnail card",
                //        Subtitle = "Pig Latin Wikipedia Page",
                //        Images = cardImages,
                //        Buttons = cardButtons
                //    };
                //    Attachment plAttachment = plCard.ToAttachment();
                //    replyToConversation.Attachments.Add(plAttachment);
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);


                //}
                //else if (activity.Text == "4")
                //{
                //    Activity replyToConversation = activity.CreateReply("Receipt card");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.Attachments = new List<Attachment>();
                //    List<CardImage> cardImages = new List<CardImage>();
                //    cardImages.Add(new CardImage(url: "http://pic.qiantucdn.com/58pic/17/41/38/88658PICNuP_1024.jpg"));
                //    List<CardAction> cardButtons = new List<CardAction>();
                //    CardAction plButton = new CardAction()
                //    {
                //        Value = "https://www.baidu.com",
                //        Type = "openUrl",
                //        Title = "WikiPedia Page"
                //    };
                //    cardButtons.Add(plButton);
                //    ReceiptItem lineItem1 = new ReceiptItem()
                //    {
                //        Title = "Pork Shoulder",
                //        Subtitle = "8 lbs",
                //        Text = null,
                //        Image = new CardImage(url: "http://pic.qiantucdn.com/58pic/17/41/38/88658PICNuP_1024.jpg"),
                //        Price = "16.25",
                //        Quantity = "1",
                //        Tap = null
                //    };
                //    ReceiptItem lineItem2 = new ReceiptItem()
                //    {
                //        Title = "Bacon",
                //        Subtitle = "5 lbs",
                //        Text = null,
                //        Image = new CardImage(url: "http://pic.qiantucdn.com/58pic/17/41/38/88658PICNuP_1024.jpg"),
                //        Price = "34.50",
                //        Quantity = "2",
                //        Tap = null
                //    };
                //    List<ReceiptItem> receiptList = new List<ReceiptItem>();
                //    receiptList.Add(lineItem1);
                //    receiptList.Add(lineItem2);
                //    ReceiptCard plCard = new ReceiptCard()
                //    {
                //        Title = "I'm a receipt card, isn't this bacon expensive?",
                //        Buttons = cardButtons,
                //        Items = receiptList,
                //        Total = "275.25",
                //        Tax = "27.52"
                //    };
                //    Attachment plAttachment = plCard.ToAttachment();
                //    replyToConversation.Attachments.Add(plAttachment);
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                //}
                //else if (activity.Text == "5")
                //{
                //    Activity replyToConversation = activity.CreateReply("Should go to conversation, with a carousel");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    replyToConversation.Attachments = new List<Attachment>();
                //    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
                //    cardContentList.Add("PigLatin", "http://img.taopic.com/uploads/allimg/140324/267861-14032421510254.jpg");


                //    foreach (KeyValuePair<string, string> cardContent in cardContentList)
                //    {
                //        List<CardImage> cardImages = new List<CardImage>();
                //        cardImages.Add(new CardImage(url: cardContent.Value));
                //        List<CardAction> cardButtons = new List<CardAction>();
                //        CardAction uplButton = new CardAction()
                //        {
                //            Value = "上一页",
                //            Type = "postBack",
                //            Title = "上一页"
                //        };
                //        cardButtons.Add(uplButton);
                //        CardAction plButton = new CardAction()
                //        {
                //            Value = "http://pbiembedtestweb.azurewebsites.net/Dashboard/Report?reportId=89957040-2963-4015-adbc-c169bfff0738",
                //            Type = "openUrl",
                //            Title = "打开报表"
                //        };
                //        cardButtons.Add(plButton);

                //        CardAction dplButton = new CardAction()
                //        {
                //            Value = "下一页",
                //            Type = "postBack",
                //            Title = "下一页"
                //        };
                //        cardButtons.Add(dplButton);
                //        HeroCard plCard = new HeroCard()
                //        {
                //            Title = "",
                //            Subtitle = "",
                //            Images = cardImages,
                //            Buttons = cardButtons
                //        };
                //        Attachment plAttachment = plCard.ToAttachment();
                //        replyToConversation.Attachments.Add(plAttachment);
                //    }
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                //}
                //else if (activity.Text == "下一页")
                //{
                //    Activity replyToConversation = activity.CreateReply("Should go to conversation, with a carousel");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    replyToConversation.Attachments = new List<Attachment>();
                //    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
                //    cardContentList.Add("Pork Shoulder", "http://pic40.nipic.com/20140415/2531170_191119071000_2.jpg");

                //    foreach (KeyValuePair<string, string> cardContent in cardContentList)
                //    {
                //        List<CardImage> cardImages = new List<CardImage>();
                //        cardImages.Add(new CardImage(url: cardContent.Value));
                //        List<CardAction> cardButtons = new List<CardAction>();
                //        CardAction uplButton = new CardAction()
                //        {
                //            Value = "上一页",
                //            Type = "postBack",
                //            Title = "上一页"
                //        };
                //        cardButtons.Add(uplButton);
                //        CardAction plButton = new CardAction()
                //        {
                //            Value = "http://pbiembedtestweb.azurewebsites.net/Dashboard/Report?reportId=89957040-2963-4015-adbc-c169bfff0738",
                //            Type = "openUrl",
                //            Title = "打开报表"
                //        };
                //        cardButtons.Add(plButton);

                //        CardAction dplButton = new CardAction()
                //        {
                //            Value = "下一页",
                //            Type = "postBack",
                //            Title = "下一页"
                //        };
                //        cardButtons.Add(dplButton);
                //        HeroCard plCard = new HeroCard()
                //        {
                //            Title = "",
                //            Subtitle = "",
                //            Images = cardImages,
                //            Buttons = cardButtons
                //        };
                //        Attachment plAttachment = plCard.ToAttachment();
                //        replyToConversation.Attachments.Add(plAttachment);
                //    }
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                //}
                //else if (activity.Text == "上一页")
                //{
                //    Activity replyToConversation = activity.CreateReply("Should go to conversation, with a carousel");
                //    replyToConversation.Recipient = activity.From;
                //    replyToConversation.Type = "message";
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    replyToConversation.Attachments = new List<Attachment>();
                //    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
                //    cardContentList.Add("Bacon", "http://pic40.nipic.com/20140412/2531170_084639470000_2.jpg");

                //    foreach (KeyValuePair<string, string> cardContent in cardContentList)
                //    {
                //        List<CardImage> cardImages = new List<CardImage>();
                //        cardImages.Add(new CardImage(url: cardContent.Value));
                //        List<CardAction> cardButtons = new List<CardAction>();
                //        CardAction uplButton = new CardAction()
                //        {
                //            Value = "上一页",
                //            Type = "postBack",
                //            Title = "上一页"
                //        };
                //        cardButtons.Add(uplButton);
                //        CardAction plButton = new CardAction()
                //        {
                //            Value = "http://pbiembedtestweb.azurewebsites.net/Dashboard/Report?reportId=89957040-2963-4015-adbc-c169bfff0738",
                //            Type = "openUrl",
                //            Title = "打开报表"
                //        };
                //        cardButtons.Add(plButton);

                //        CardAction dplButton = new CardAction()
                //        {
                //            Value = "下一页",
                //            Type = "postBack",
                //            Title = "下一页"
                //        };
                //        cardButtons.Add(dplButton);
                //        HeroCard plCard = new HeroCard()
                //        {
                //            Title = "",
                //            Subtitle = "",
                //            Images = cardImages,
                //            Buttons = cardButtons
                //        };
                //        Attachment plAttachment = plCard.ToAttachment();
                //        replyToConversation.Attachments.Add(plAttachment);
                //    }
                //    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                //}
                //else if (activity.Text == "6")
                //{

                //}
                //else if (activity.Text == "7")
                //{


                //}
                //else if (activity.Text == "8")
                //{

                //}
                //else if (activity.Text == "9")
                //{

                //}
                //else if (activity.Text == "10")
                //{

                //}
                //else
                //{
                //    //Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters");

                //    //await connector.Conversations.ReplyToActivityAsync(reply);
                //    await Conversation.SendAsync(activity, () => new WeatherDialog());
                //}
                #endregion
                #region CRM一部打单应用
//                bool UnAnswerFlag = true;
//                if (activity.Text.Contains("你好") || activity.Text.Contains("您好"))
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"您好！";
//                    Activity reply = activity.CreateReply(replyStr);
//                    await connector.Conversations.ReplyToActivityAsync(reply);
//                    System.Threading.Thread.Sleep(1000);
//                    string replyStr1 = @"有什么可以帮到您！";
//                    Activity reply1 = activity.CreateReply(replyStr1);
//                    await connector.Conversations.ReplyToActivityAsync(reply1);
//                }
//                if (activity.Text.Contains("注册"))
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"1. 点击左上角注册按钮
//2. 填写基本信息，并点击注册按钮
//3. 注册成功后等待普莱克斯客户管理员审核
//4. 审核完成后，将有邮件通知";
//                    Activity reply = activity.CreateReply(replyStr);
//                    await connector.Conversations.ReplyToActivityAsync(reply);
//                }
//                if (activity.Text.Contains("产品信息"))
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"输入产品查询条件，可选择查询1.产品描述、2.产品价格、3.图片
//查询条件可不用学习，输入全称或者/后的简称均可查询产品";
//                    Activity reply = activity.CreateReply(replyStr);
//                    await connector.Conversations.ReplyToActivityAsync(reply);
//                }
//                if (activity.Text.Contains("客户编号"))
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"请联系我们：
//86-21-28947000 
//400-800-1717";
//                    Activity reply = activity.CreateReply(replyStr);
//                    await connector.Conversations.ReplyToActivityAsync(reply);
//                }
//                if (activity.Text.Replace(" ","")=="S1-1-KS1616集装格氧气40L135bar")
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"产品信息";
//                    Activity replyToConversation = activity.CreateReply(replyStr);
//                    replyToConversation.Recipient = activity.From;
//                    replyToConversation.Type = "message";
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    replyToConversation.Attachments = new List<Attachment>();
//                    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
//                    cardContentList.Add("Bacon", "http://botweb.chinacloudsites.cn/Images/dome1/KS15.jpg");

//                    foreach (KeyValuePair<string, string> cardContent in cardContentList)
//                    {
//                        List<CardImage> cardImages = new List<CardImage>();
//                        cardImages.Add(new CardImage(url: cardContent.Value));
//                        List<CardAction> cardButtons = new List<CardAction>();

//                        CardAction plButton = new CardAction()
//                        {
//                            Value = "http://nopcommercedemo.chinacloudsites.cn/s5094-7-ks-%E9%AB%98%E7%BA%AF%E6%B0%A7-99999-50l-150bar",
//                            Type = "openUrl",
//                            Title = "去购买"
//                        };
//                        cardButtons.Add(plButton);

//                        HeroCard plCard = new HeroCard()
//                        {
//                            Subtitle= "产品描述:氧气可以通过空气分离获得。氧气在参与氧化反应和维持生命中起到至关重要的作用。在工业上，它被广泛用于金属加工行业进行冶炼和金属切割。典型的用途是与乙炔混合产生氧/乙炔火焰，温度可超过3000°C。",
//                            Title = "产品价格:50 RMB",
//                            Images = cardImages,
//                            Buttons = cardButtons
//                        };
//                        Attachment plAttachment = plCard.ToAttachment();
//                        replyToConversation.Attachments.Add(plAttachment);
//                    }
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
//                }
//                if (activity.Text== "KS16")
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @"产品信息";
//                    Activity replyToConversation = activity.CreateReply(replyStr);
//                    replyToConversation.Recipient = activity.From;
//                    replyToConversation.Type = "message";
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    replyToConversation.Attachments = new List<Attachment>();
//                    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
//                    cardContentList.Add("Bacon", "http://botweb.chinacloudsites.cn/Images/dome1/KS15.jpg");

//                    foreach (KeyValuePair<string, string> cardContent in cardContentList)
//                    {
//                        List<CardImage> cardImages = new List<CardImage>();
//                        cardImages.Add(new CardImage(url: cardContent.Value));
//                        List<CardAction> cardButtons = new List<CardAction>();
                       
//                        CardAction plButton = new CardAction()
//                        {
//                            Value = "http://nopcommercedemo.chinacloudsites.cn/s5094-7-ks-%E9%AB%98%E7%BA%AF%E6%B0%A7-99999-50l-150bar",
//                            Type = "openUrl",
//                            Title = "去购买"
//                        };
//                        cardButtons.Add(plButton);
 
//                        HeroCard plCard = new HeroCard()
//                        {
//                            Subtitle = "产品描述:氧气可以通过空气分离获得。氧气在参与氧化反应和维持生命中起到至关重要的作用。在工业上，它被广泛用于金属加工行业进行冶炼和金属切割。典型的用途是与乙炔混合产生氧/乙炔火焰，温度可超过3000°C。",
//                            Title = "产品价格:50 RMB",
//                            Images = cardImages,
//                            Buttons = cardButtons
//                        };
//                        Attachment plAttachment = plCard.ToAttachment();
//                        replyToConversation.Attachments.Add(plAttachment);
//                    }
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
//                }
//                if (activity.Text.Replace(" ", "") == "554PCC200-16B液氧杜瓦200L16bar")
//                {
//                    UnAnswerFlag = false;
//                    string replyStr = @" 产品信息";
//                    Activity replyToConversation = activity.CreateReply(replyStr);
//                    replyToConversation.Recipient = activity.From;
//                    replyToConversation.Type = "message";
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    replyToConversation.Attachments = new List<Attachment>();
//                    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
//                    cardContentList.Add("Bacon", "http://botweb.chinacloudsites.cn/Images/dome1/554PCC200.jpg");

//                    foreach (KeyValuePair<string, string> cardContent in cardContentList)
//                    {
//                        List<CardImage> cardImages = new List<CardImage>();
//                        cardImages.Add(new CardImage(url: cardContent.Value));
//                        List<CardAction> cardButtons = new List<CardAction>();

//                        CardAction plButton = new CardAction()
//                        {
//                            Value = "http://nopcommercedemo.chinacloudsites.cn/554pcc200-16b-%E6%B6%B2%E6%B0%A7%E6%9D%9C%E7%93%A6-200l-16bar",
//                            Type = "openUrl",
//                            Title = "去购买"
//                        };
//                        cardButtons.Add(plButton);

//                        HeroCard plCard = new HeroCard()
//                        {
//                            Subtitle = "产品描述:在工业上，它被广泛用于金属加工行业进行冶炼和金属切割。典型的用途是与乙炔混合产生氧/乙炔火焰，温度可超过3000°C。",
//                            Title = "产品价格:200 RMB",
//                            Images = cardImages,
//                            Buttons = cardButtons
//                        };
//                        Attachment plAttachment = plCard.ToAttachment();
//                        replyToConversation.Attachments.Add(plAttachment);
//                    }
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
//                }
//                if (activity.Text == "液氧")
//                {
//                    UnAnswerFlag = false;
//                    Activity replyToConversation = activity.CreateReply("产品信息");
//                    replyToConversation.Recipient = activity.From;
//                    replyToConversation.Type = "message";
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    replyToConversation.Attachments = new List<Attachment>();
//                    Dictionary<string, string> cardContentList = new Dictionary<string, string>();
//                    cardContentList.Add("Bacon", "http://botweb.chinacloudsites.cn/Images/dome1/554PCC200.jpg");

//                    foreach (KeyValuePair<string, string> cardContent in cardContentList)
//                    {
//                        List<CardImage> cardImages = new List<CardImage>();
//                        cardImages.Add(new CardImage(url: cardContent.Value));
//                        List<CardAction> cardButtons = new List<CardAction>();

//                        CardAction plButton = new CardAction()
//                        {
//                            Value = "http://nopcommercedemo.chinacloudsites.cn/554pcc200-16b-%E6%B6%B2%E6%B0%A7%E6%9D%9C%E7%93%A6-200l-16bar",
//                            Type = "openUrl",
//                            Title = "去购买"
//                        };
//                        cardButtons.Add(plButton);

//                        HeroCard plCard = new HeroCard()
//                        {
//                            Subtitle = "产品描述:在工业上，它被广泛用于金属加工行业进行冶炼和金属切割。典型的用途是与乙炔混合产生氧/乙炔火焰，温度可超过3000°C。",
//                            Title = "产品价格:200 RMB",
//                            Images = cardImages,
//                            Buttons = cardButtons
//                        };
//                        Attachment plAttachment = plCard.ToAttachment();
//                        replyToConversation.Attachments.Add(plAttachment);
//                    }
//                    replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
//                    var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
//                }
//                if(UnAnswerFlag) {
//                    string replyStr = @"请联系我们：
//86-21-28947000 
//400-800-1717";
//                    Activity reply = activity.CreateReply(replyStr);
//                    await connector.Conversations.ReplyToActivityAsync(reply);
//                }

                #endregion

                await Conversation.SendAsync(activity, () => new WeatherDialog());
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);
            return response;
        }

        private Activity HandleSystemMessage(Activity message)
        {
            if (message.Type == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (message.Type == ActivityTypes.ConversationUpdate)
            {
                // Handle conversation state changes, like members being added and removed
                // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
                // Not available in all channels
            }
            else if (message.Type == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (message.Type == ActivityTypes.Typing)
            {
                // Handle knowing tha the user is typing
            }
            else if (message.Type == ActivityTypes.Ping)
            {
            }

            return null;
        }
    }
}